<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root">
      <div class="tab-bar">
        <a href="#/home">首页</a>
        <a href="#/about">关于</a>
      </div>

      <div class="router-view">暂无</div>
    </div>

    <script>
      var routerViewEl = document.querySelector('.router-view')
      // console.log(routerViewEl)

      // 监听 hash 变更
      window.addEventListener('hashchange', (e) => {
        const hash = window.location.hash
        console.log(`hash 改变啦 ${hash}`)
        switch (hash) {
          case '#/home':
            routerViewEl.innerHTML = '首页'
            break
          case '#/about':
            routerViewEl.innerHTML = '关于'
            break
          default:
            break
        }
      })
    </script>
  </body>
</html>
